// ignore_for_file: type=lint

import 'package:json_annotation/json_annotation.dart';
import 'package:json_annotation/json_annotation.dart' as json;
import 'package:collection/collection.dart';
import 'dart:convert';

import 'example.models.swagger.dart';
import 'package:chopper/chopper.dart';

import 'client_mapping.dart';
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:http/http.dart' show MultipartFile;
import 'package:chopper/chopper.dart' as chopper;
import 'example.enums.swagger.dart' as enums;
export 'example.enums.swagger.dart';
export 'example.models.swagger.dart';

part 'example.swagger.chopper.dart';

// **************************************************************************
// SwaggerChopperGenerator
// **************************************************************************

@ChopperApi()
abstract class Example extends ChopperService {
  static Example create({
    ChopperClient? client,
    http.Client? httpClient,
    Authenticator? authenticator,
    ErrorConverter? errorConverter,
    Converter? converter,
    Uri? baseUrl,
    List<Interceptor>? interceptors,
  }) {
    if (client != null) {
      return _$Example(client);
    }

    final newClient = ChopperClient(
      services: [_$Example()],
      converter: converter ?? $JsonSerializableConverter(),
      interceptors: interceptors ?? [],
      client: httpClient,
      authenticator: authenticator,
      errorConverter: errorConverter,
      baseUrl: baseUrl ?? Uri.parse('http://'),
    );
    return _$Example(newClient);
  }

  ///创建用户
  Future<chopper.Response<AppUsersPostResponse>> appUsersPost({
    dynamic cacheControl,
    required CreateUserDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersPostResponse,
      () => AppUsersPostResponse.fromJsonFactory,
    );

    return _appUsersPost(cacheControl: cacheControl?.toString(), body: body);
  }

  ///创建用户
  @POST(path: '/app/users', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response<AppUsersPostResponse>> _appUsersPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateUserDto body,
  });

  ///分页获取用户列表
  ///@param page 页码
  ///@param pageSize 每页数量
  Future<chopper.Response<AppUsersGetResponse>> appUsersGet({
    num? page,
    num? pageSize,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersGetResponse,
      () => AppUsersGetResponse.fromJsonFactory,
    );

    return _appUsersGet(
      page: page,
      pageSize: pageSize,
      cacheControl: cacheControl?.toString(),
    );
  }

  ///分页获取用户列表
  ///@param page 页码
  ///@param pageSize 每页数量
  @GET(path: '/app/users', includeNullQueryVars: true)
  Future<chopper.Response<AppUsersGetResponse>> _appUsersGet({
    @Query('page') num? page,
    @Query('pageSize') num? pageSize,
    @Header('Cache-Control') String? cacheControl,
  });

  ///用户登录
  Future<chopper.Response<AppUsersLoginPostResponse>> appUsersLoginPost({
    dynamic cacheControl,
    required LoginDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersLoginPostResponse,
      () => AppUsersLoginPostResponse.fromJsonFactory,
    );

    return _appUsersLoginPost(
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///用户登录
  @POST(
    path: '/app/users/login',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppUsersLoginPostResponse>> _appUsersLoginPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required LoginDto body,
  });

  ///根据ID获取用户
  ///@param id 用户ID
  Future<chopper.Response<AppUsersIdGetResponse>> appUsersIdGet({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersIdGetResponse,
      () => AppUsersIdGetResponse.fromJsonFactory,
    );

    return _appUsersIdGet(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID获取用户
  ///@param id 用户ID
  @GET(path: '/app/users/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppUsersIdGetResponse>> _appUsersIdGet({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID更新用户
  ///@param id 用户ID
  Future<chopper.Response<AppUsersIdPatchResponse>> appUsersIdPatch({
    required String? id,
    dynamic cacheControl,
    required UpdateUserDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersIdPatchResponse,
      () => AppUsersIdPatchResponse.fromJsonFactory,
    );

    return _appUsersIdPatch(
      id: id,
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///根据ID更新用户
  ///@param id 用户ID
  @PATCH(
    path: '/app/users/{id}',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppUsersIdPatchResponse>> _appUsersIdPatch({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
    @Body() required UpdateUserDto body,
  });

  ///根据ID删除用户
  ///@param id 用户ID
  Future<chopper.Response<AppUsersIdDeleteResponse>> appUsersIdDelete({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppUsersIdDeleteResponse,
      () => AppUsersIdDeleteResponse.fromJsonFactory,
    );

    return _appUsersIdDelete(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID删除用户
  ///@param id 用户ID
  @DELETE(path: '/app/users/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppUsersIdDeleteResponse>> _appUsersIdDelete({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> testSseGet({
    dynamic cacheControl,
    required CreateTestDto body,
  }) {
    return _testSseGet(cacheControl: cacheControl?.toString(), body: body);
  }

  ///
  @GET(path: '/test/sse', includeNullQueryVars: true)
  Future<chopper.Response> _testSseGet({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateTestDto body,
  });

  ///
  Future<chopper.Response> testPostTestPost({dynamic cacheControl}) {
    return _testPostTestPost(cacheControl: cacheControl?.toString());
  }

  ///
  @POST(path: '/test/post-test', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response> _testPostTestPost({
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> testSendDataPost({dynamic cacheControl}) {
    return _testSendDataPost(cacheControl: cacheControl?.toString());
  }

  ///
  @POST(path: '/test/send-data', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response> _testSendDataPost({
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> testEndConnectionPost({dynamic cacheControl}) {
    return _testEndConnectionPost(cacheControl: cacheControl?.toString());
  }

  ///
  @POST(
    path: '/test/end-connection',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response> _testEndConnectionPost({
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> testDecoratorSsePost({dynamic cacheControl}) {
    return _testDecoratorSsePost(cacheControl: cacheControl?.toString());
  }

  ///
  @POST(
    path: '/test/decorator-sse',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response> _testDecoratorSsePost({
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> testAdvancedSsePost({dynamic cacheControl}) {
    return _testAdvancedSsePost(cacheControl: cacheControl?.toString());
  }

  ///
  @POST(
    path: '/test/advanced-sse',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response> _testAdvancedSsePost({
    @Header('Cache-Control') String? cacheControl,
  });

  ///
  Future<chopper.Response> appChatPost({
    dynamic cacheControl,
    required CreateChatDto body,
  }) {
    return _appChatPost(cacheControl: cacheControl?.toString(), body: body);
  }

  ///
  @POST(path: '/app/chat', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response> _appChatPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateChatDto body,
  });

  ///创建记账
  Future<chopper.Response<AppLedgerPostResponse>> appLedgerPost({
    dynamic cacheControl,
    required CreateLedgerDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerPostResponse,
      () => AppLedgerPostResponse.fromJsonFactory,
    );

    return _appLedgerPost(cacheControl: cacheControl?.toString(), body: body);
  }

  ///创建记账
  @POST(path: '/app/ledger', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response<AppLedgerPostResponse>> _appLedgerPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateLedgerDto body,
  });

  ///获取记账列表
  ///@param page 页码
  ///@param pageSize 每页数量
  Future<chopper.Response<AppLedgerGetResponse>> appLedgerGet({
    num? page,
    num? pageSize,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerGetResponse,
      () => AppLedgerGetResponse.fromJsonFactory,
    );

    return _appLedgerGet(
      page: page,
      pageSize: pageSize,
      cacheControl: cacheControl?.toString(),
    );
  }

  ///获取记账列表
  ///@param page 页码
  ///@param pageSize 每页数量
  @GET(path: '/app/ledger', includeNullQueryVars: true)
  Future<chopper.Response<AppLedgerGetResponse>> _appLedgerGet({
    @Query('page') num? page,
    @Query('pageSize') num? pageSize,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID获取记账
  ///@param id
  Future<chopper.Response<AppLedgerIdGetResponse>> appLedgerIdGet({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerIdGetResponse,
      () => AppLedgerIdGetResponse.fromJsonFactory,
    );

    return _appLedgerIdGet(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID获取记账
  ///@param id
  @GET(path: '/app/ledger/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppLedgerIdGetResponse>> _appLedgerIdGet({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID更新记账
  ///@param id
  Future<chopper.Response<AppLedgerIdPatchResponse>> appLedgerIdPatch({
    required String? id,
    dynamic cacheControl,
    required UpdateLedgerDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerIdPatchResponse,
      () => AppLedgerIdPatchResponse.fromJsonFactory,
    );

    return _appLedgerIdPatch(
      id: id,
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///根据ID更新记账
  ///@param id
  @PATCH(
    path: '/app/ledger/{id}',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppLedgerIdPatchResponse>> _appLedgerIdPatch({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
    @Body() required UpdateLedgerDto body,
  });

  ///根据ID删除记账
  ///@param id
  Future<chopper.Response<AppLedgerIdDeleteResponse>> appLedgerIdDelete({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerIdDeleteResponse,
      () => AppLedgerIdDeleteResponse.fromJsonFactory,
    );

    return _appLedgerIdDelete(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID删除记账
  ///@param id
  @DELETE(path: '/app/ledger/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppLedgerIdDeleteResponse>> _appLedgerIdDelete({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///请求ai评论
  Future<chopper.Response<AppLedgerAiCommentPostResponse>>
  appLedgerAiCommentPost({
    dynamic cacheControl,
    required LedgerAiCommentDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppLedgerAiCommentPostResponse,
      () => AppLedgerAiCommentPostResponse.fromJsonFactory,
    );

    return _appLedgerAiCommentPost(
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///请求ai评论
  @POST(
    path: '/app/ledger/ai-comment',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppLedgerAiCommentPostResponse>>
  _appLedgerAiCommentPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required LedgerAiCommentDto body,
  });

  ///创建待办
  Future<chopper.Response<AppTodoPostResponse>> appTodoPost({
    dynamic cacheControl,
    required CreateTodoDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoPostResponse,
      () => AppTodoPostResponse.fromJsonFactory,
    );

    return _appTodoPost(cacheControl: cacheControl?.toString(), body: body);
  }

  ///创建待办
  @POST(path: '/app/todo', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response<AppTodoPostResponse>> _appTodoPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateTodoDto body,
  });

  ///获取待办列表
  ///@param page 页码
  ///@param pageSize 每页数量
  Future<chopper.Response<AppTodoGetResponse>> appTodoGet({
    num? page,
    num? pageSize,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoGetResponse,
      () => AppTodoGetResponse.fromJsonFactory,
    );

    return _appTodoGet(
      page: page,
      pageSize: pageSize,
      cacheControl: cacheControl?.toString(),
    );
  }

  ///获取待办列表
  ///@param page 页码
  ///@param pageSize 每页数量
  @GET(path: '/app/todo', includeNullQueryVars: true)
  Future<chopper.Response<AppTodoGetResponse>> _appTodoGet({
    @Query('page') num? page,
    @Query('pageSize') num? pageSize,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID获取待办
  ///@param id
  Future<chopper.Response<AppTodoIdGetResponse>> appTodoIdGet({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoIdGetResponse,
      () => AppTodoIdGetResponse.fromJsonFactory,
    );

    return _appTodoIdGet(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID获取待办
  ///@param id
  @GET(path: '/app/todo/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppTodoIdGetResponse>> _appTodoIdGet({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///更新待办
  ///@param id
  Future<chopper.Response<AppTodoIdPatchResponse>> appTodoIdPatch({
    required String? id,
    dynamic cacheControl,
    required UpdateTodoDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoIdPatchResponse,
      () => AppTodoIdPatchResponse.fromJsonFactory,
    );

    return _appTodoIdPatch(
      id: id,
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///更新待办
  ///@param id
  @PATCH(path: '/app/todo/{id}', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response<AppTodoIdPatchResponse>> _appTodoIdPatch({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
    @Body() required UpdateTodoDto body,
  });

  ///删除待办
  ///@param id
  Future<chopper.Response<AppTodoIdDeleteResponse>> appTodoIdDelete({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoIdDeleteResponse,
      () => AppTodoIdDeleteResponse.fromJsonFactory,
    );

    return _appTodoIdDelete(id: id, cacheControl: cacheControl?.toString());
  }

  ///删除待办
  ///@param id
  @DELETE(path: '/app/todo/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppTodoIdDeleteResponse>> _appTodoIdDelete({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///请求ai评论
  Future<chopper.Response<AppTodoAiCommentPostResponse>> appTodoAiCommentPost({
    dynamic cacheControl,
    required TodoAiCommentDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppTodoAiCommentPostResponse,
      () => AppTodoAiCommentPostResponse.fromJsonFactory,
    );

    return _appTodoAiCommentPost(
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///请求ai评论
  @POST(
    path: '/app/todo/ai-comment',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppTodoAiCommentPostResponse>> _appTodoAiCommentPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required TodoAiCommentDto body,
  });

  ///创建日记
  Future<chopper.Response<AppJournalPostResponse>> appJournalPost({
    dynamic cacheControl,
    required CreateJournalDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppJournalPostResponse,
      () => AppJournalPostResponse.fromJsonFactory,
    );

    return _appJournalPost(cacheControl: cacheControl?.toString(), body: body);
  }

  ///创建日记
  @POST(path: '/app/journal', optionalBody: true, includeNullQueryVars: true)
  Future<chopper.Response<AppJournalPostResponse>> _appJournalPost({
    @Header('Cache-Control') String? cacheControl,
    @Body() required CreateJournalDto body,
  });

  ///获取日记列表
  ///@param page 页码
  ///@param pageSize 每页数量
  Future<chopper.Response<AppJournalGetResponse>> appJournalGet({
    num? page,
    num? pageSize,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppJournalGetResponse,
      () => AppJournalGetResponse.fromJsonFactory,
    );

    return _appJournalGet(
      page: page,
      pageSize: pageSize,
      cacheControl: cacheControl?.toString(),
    );
  }

  ///获取日记列表
  ///@param page 页码
  ///@param pageSize 每页数量
  @GET(path: '/app/journal', includeNullQueryVars: true)
  Future<chopper.Response<AppJournalGetResponse>> _appJournalGet({
    @Query('page') num? page,
    @Query('pageSize') num? pageSize,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID获取日记
  ///@param id
  Future<chopper.Response<AppJournalIdGetResponse>> appJournalIdGet({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppJournalIdGetResponse,
      () => AppJournalIdGetResponse.fromJsonFactory,
    );

    return _appJournalIdGet(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID获取日记
  ///@param id
  @GET(path: '/app/journal/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppJournalIdGetResponse>> _appJournalIdGet({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });

  ///根据ID更新日记
  ///@param id
  Future<chopper.Response<AppJournalIdPatchResponse>> appJournalIdPatch({
    required String? id,
    dynamic cacheControl,
    required UpdateJournalDto body,
  }) {
    generatedMapping.putIfAbsent(
      AppJournalIdPatchResponse,
      () => AppJournalIdPatchResponse.fromJsonFactory,
    );

    return _appJournalIdPatch(
      id: id,
      cacheControl: cacheControl?.toString(),
      body: body,
    );
  }

  ///根据ID更新日记
  ///@param id
  @PATCH(
    path: '/app/journal/{id}',
    optionalBody: true,
    includeNullQueryVars: true,
  )
  Future<chopper.Response<AppJournalIdPatchResponse>> _appJournalIdPatch({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
    @Body() required UpdateJournalDto body,
  });

  ///根据ID删除日记
  ///@param id
  Future<chopper.Response<AppJournalIdDeleteResponse>> appJournalIdDelete({
    required String? id,
    dynamic cacheControl,
  }) {
    generatedMapping.putIfAbsent(
      AppJournalIdDeleteResponse,
      () => AppJournalIdDeleteResponse.fromJsonFactory,
    );

    return _appJournalIdDelete(id: id, cacheControl: cacheControl?.toString());
  }

  ///根据ID删除日记
  ///@param id
  @DELETE(path: '/app/journal/{id}', includeNullQueryVars: true)
  Future<chopper.Response<AppJournalIdDeleteResponse>> _appJournalIdDelete({
    @Path('id') required String? id,
    @Header('Cache-Control') String? cacheControl,
  });
}

typedef $JsonFactory<T> = T Function(Map<String, dynamic> json);

class $CustomJsonDecoder {
  $CustomJsonDecoder(this.factories);

  final Map<Type, $JsonFactory> factories;

  dynamic decode<T>(dynamic entity) {
    if (entity is Iterable) {
      return _decodeList<T>(entity);
    }

    if (entity is T) {
      return entity;
    }

    if (isTypeOf<T, Map>()) {
      return entity;
    }

    if (isTypeOf<T, Iterable>()) {
      return entity;
    }

    if (entity is Map<String, dynamic>) {
      return _decodeMap<T>(entity);
    }

    return entity;
  }

  T _decodeMap<T>(Map<String, dynamic> values) {
    final jsonFactory = factories[T];
    if (jsonFactory == null || jsonFactory is! $JsonFactory<T>) {
      return throw "Could not find factory for type $T. Is '$T: $T.fromJsonFactory' included in the CustomJsonDecoder instance creation in bootstrapper.dart?";
    }

    return jsonFactory(values);
  }

  List<T> _decodeList<T>(Iterable values) =>
      values.where((v) => v != null).map<T>((v) => decode<T>(v) as T).toList();
}

class $JsonSerializableConverter extends chopper.JsonConverter {
  @override
  FutureOr<chopper.Response<ResultType>> convertResponse<ResultType, Item>(
    chopper.Response response,
  ) async {
    if (response.bodyString.isEmpty) {
      // In rare cases, when let's say 204 (no content) is returned -
      // we cannot decode the missing json with the result type specified
      return chopper.Response(response.base, null, error: response.error);
    }

    if (ResultType == String) {
      return response.copyWith();
    }

    if (ResultType == DateTime) {
      return response.copyWith(
        body:
            DateTime.parse((response.body as String).replaceAll('"', ''))
                as ResultType,
      );
    }

    final jsonRes = await super.convertResponse(response);
    return jsonRes.copyWith<ResultType>(
      body: $jsonDecoder.decode<Item>(jsonRes.body) as ResultType,
    );
  }
}

final $jsonDecoder = $CustomJsonDecoder(generatedMapping);
